package com.ag.text;

import com.ag.utils.DictionarySettingUtils;
import com.ag.utils.MessageFormatter;

public class DicTextDelegating {
	
	public final static String DIC_CONTENTTMPL_PRE = "text.contenttmpl.{}";
	public final static String DIC_TITLE_PRE = "text.title.{}";
	
	String simpleClassName;
	public DicTextDelegating(Object target) {
		Class<?> clazz = target.getClass();
		simpleClassName = clazz.getSimpleName().substring(0,1).toLowerCase() + clazz.getSimpleName().substring(1);
	}
	
	private String getSimpleClassName() {
		return simpleClassName;
	}
	
	protected String getTitleTpmlWithDefault(String d) {
		String k = MessageFormatter.format(DIC_TITLE_PRE, getSimpleClassName());
		
		return DictionarySettingUtils.getParameterValueWithDefault(k, d);
	}
	
	protected String  getTitleTpmlSuffixWithDefault(String d, String suffix) {
		String k = MessageFormatter.format(DIC_TITLE_PRE + suffix, getSimpleClassName());
		
		return DictionarySettingUtils.getParameterValueWithDefault(k, d);
	}
	
	protected String getContentTmplWithDefault(String d) {
		String k = MessageFormatter.format(DIC_CONTENTTMPL_PRE, getSimpleClassName());
		return DictionarySettingUtils.getParameterValueWithDefault(k, d);
	}
	
	protected String getContentTmplSuffixWithDefault(String d, String suffix) {
		String k = MessageFormatter.format(DIC_CONTENTTMPL_PRE + suffix, getSimpleClassName());
		return DictionarySettingUtils.getParameterValueWithDefault(k, d);
	}
}
